package com.example.demo.vo;

import com.example.demo.dao.User;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserVoEx {
    private int id;
    private String account;
    private String name;
    private int age;
    private int sex;
    private String phone;
    private int roleId;
    private String isValid;

    // 如果互相转换
    public static UserVoEx exchange(User user){
        UserVoEx userVoEx = new UserVoEx();
        BeanUtils.copyProperties(user,userVoEx);
        return userVoEx;
    }

    public static User exchange(UserVoEx userVoEx){
        User user = new User();
        BeanUtils.copyProperties(userVoEx,user);
        return user;
    }
}
